package com.yjhb.android.sbz.activity;

import android.content.Intent;
import android.graphics.Color;
import android.widget.TextView;

import com.yjhb.android.sbz.R;
import com.yjhb.android.sbz.App;
import com.yjhb.android.sbz.tool.EventMsg;
import com.yjhb.android.sbz.tool.Tool;
import com.jojo.android.zxlib.base.mvp.BasePresenter;
import com.jojo.android.zxlib.tool.ZxLogTool;
import com.jojo.android.zxlib.tool.ZxSpanTool;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 创建者 zx
 * 创建时间 2020/12/8 12:00
 */
public class BondMoneyActivity extends BaseActivity {
    private final String TAG = "BondMoneyActivity";
    @BindView(R.id.balance_tv)
    TextView balance_tv;
    @BindView(R.id.tips_tv)
    TextView tips_tv;

    @Override
    protected BasePresenter initPresenter() {
        return null;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_bond_money;
    }

    @Override
    protected void initUI() {
        CharSequence tips = "1.保证金最低为100元起，可大于100元，保证金越高，您发布的任务信誉度越高，有利于您的任务快速完成;" +
                "\n2.保证金余额大于等于100元后，再发布任务列表会显示保证金标识，提交任务的信誉度，增加成交机会;" +
                "\n3.如果被投诉，平台将根据相关规定对投诉进行仲裁，跟据仲裁结果，如果对任务承接方造成了损失，会从保证金中进行处罚;" +
                "\n4.部分金融、理财、支付类任务，必须缴纳保证金后才能发布;" +
                "\n5.提交提现申请后7个工作日（除去法定节假日外），经审核无违规行为及举报，保证金全额退还;" +
                "\n6.保证金将提现收取3%的手续费;";
        try {
            tips_tv.setText(ZxSpanTool.getHighlightSpan(tips, Color.RED,"5.提交提现申请后7个工作日（除去法定节假日外），经审核无违规行为及举报，保证金全额退还;"));
        } catch (Exception e) {
            ZxLogTool.err(e);
        }
    }

    @Override
    protected void initData() {
        EventBus.getDefault().post(new EventMsg(EventMsg.REQUEST_USER_UPDATE,null));
    }

    @Override
    public void refresh() {
        balance_tv.setText(App.userInfo.getCreditMoney());
    }

    @Override
    protected void regEvent() {
    }



    @Subscribe(threadMode = ThreadMode.MAIN)
    public void eventMsg(EventMsg msg) {
        if (msg.msg == EventMsg.USER_UPDATE_OK) {
            refresh();
        }
    }

    @OnClick(R.id.back)
    public void back() {
        finish();
    }

    @OnClick(R.id.recharge_layout)
    public void recharge_layout() {
        Tool.startRechargeActivity(this,3,null,true);
    }

    @OnClick(R.id.withdrawal_layout)
    public void withdrawal_layout() {
        Intent intent = new Intent(this, WithdrawalActivity.class);
        intent.putExtra("type", 3);
        startActivity(intent);
    }
}
